﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Solidi
{
	public static class DependencyResolverExtensions
	{
		public static object Resolve(this IDependencyResolver source, IDependencyContainer container, IDependencyKey key)
		{
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

			object instance;

			if (!source.TryResolve(container, key, out instance))
			{
				throw new Exception("Could not resolve " + key);
			}

			return instance;
		}
	}
}
